package com.hiwhitley.algorithm.sort;

/**
 * Created by hiwhitley on 16-12-19.
 */
public class SelectionSort extends BaseSort {
    public static void sort(Comparable[] a) {
        int N = a.length;
        for (int i = 0; i < N; i++) {
            int min = i;
            for (int j = i + 1; j < N; j++) {
                if (less(a[j], a[min]))
                    min = j;
            }
            exch(a, i, min);
        }
    }

    public static void main(String[] args) {
        String[] strings = new String[]{"c", "b", "a"};
        sort(strings);
        show(strings);
    }
}
